package com.yunhe.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.yunhe.entity.User;
import com.yunhe.util.MyBatisUtil;

public class UserImpl implements IUser {

	SqlSession ss = MyBatisUtil.getSession();
	@Override
	public User searchByUser(User user) {
		User u = ss.selectOne("com.yunhe.dao.IUser.searchByUser", user);
		ss.close();
		return u;
	}

	@Override
	public int addUser(User user) {
		int count = ss.insert("com.yunhe.dao.IUser.addUser", user);
		ss.commit();
		ss.close();
		return count;
	}

	@Override
	public List<User> searchAllUser() {
		List<User> list = ss.selectList("com.yunhe.dao.IUser.searchAllUser");
		return list;
	}

	@Override
	public int delUser(User user) {
		int count = ss.delete("com.yunhe.dao.IUser.delUser", user);
		ss.commit();
		ss.close();
		return count;
	}

	@Override
	public int updateUser(User user) {
		int count = ss.update("com.yunhe.dao.IUser.updateUser", user);
		ss.commit();
		ss.close();
		return count;
	}

}
